package com.example.bnuzzu.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.bnuzzu.common.dto.OrderListDto;
import com.example.bnuzzu.common.dto.SearchDto;
import com.example.bnuzzu.entity.Orderinfo;
import com.example.bnuzzu.mapper.OrderinfoMapper;
import com.example.bnuzzu.service.OrderinfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author BNUZZU
 * @since 2021-04-13
 */
@Service
public class OrderinfoServiceImpl extends ServiceImpl<OrderinfoMapper, Orderinfo> implements OrderinfoService {
    @Autowired
    OrderinfoMapper orderinfoMapper;
    @Override
    public IPage<OrderListDto> selectOrderPage(Page<OrderListDto> page, Integer state){
        page.setOptimizeCountSql(false);
        return orderinfoMapper.selectPageVo(page,state);
    }

    @Override
    public IPage<OrderListDto> searchOrderPage(Page<OrderListDto> page, SearchDto searchDto, Integer state) {
        return null;
    }

    @Override
    public List<OrderListDto> getAllOrder() {
        return orderinfoMapper.getAllOrder();
    }

    /**
     * 用户查询
     */
    @Override
    public Orderinfo selectOrderinfoById(Long OrderID) {
        return orderinfoMapper.selectOrderinfoById(OrderID);
    }

    /**
     * 管理员查询
     */
    @Override
    public List<Orderinfo> selectOrderinfoList(Orderinfo orderinfo) {
        return orderinfoMapper.selectOrderinfoList(orderinfo);
    }

    @Override
    public List<OrderListDto> selectOwnOrderInfos(Integer userid) {
        return orderinfoMapper.selectOwnOrderInfos(userid);
    }

    @Override
    public List<OrderListDto> selectTenantOrderInfos(Integer userid) {
        return orderinfoMapper.selectTenantOrderInfos(userid);
    }

    /**
     * 新增
     */
    @Override
    public int insertOrderinfo(Orderinfo orderinfo) {
        return orderinfoMapper.insertOrderinfo(orderinfo);
    }

    /**
     * 修改
     */
    @Override
    public int updateOrderinfo(Orderinfo orderinfo) {
        return orderinfoMapper.updateOrderinfo(orderinfo);
    }


    /**
     * 删除
     */
    @Override
    public int deleteOrderinfoById(Long OrderID) {
        return orderinfoMapper.deleteOrderinfoById(OrderID);
    }
}
